import { stringify } from 'qs';
import request from '@utils/request';

export async function query({ page = 0, size = 10 }) {
  return request(`/api/sys/user?${stringify({ page, size })}`);
}

export async function queryCurrent() {
  return request('/api/sys/user/current');
}

export async function addUser({ username, password, code }) {
  return request('/api/sys/user', {
    method: 'POST',
    body: {
      username,
      password,
      code,
    },
  });
}

export async function updateUser({ id, avatar, nickName, email, age, roleId }) {
  return request(`/api/sys/user/${id}`, {
    method: 'PUT',
    body: {
      avatar,
      nickName,
      email,
      age,
      roleId,
    },
  });
}
